<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'wxH5Payfor.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
   <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">  
     <script type="text/javascript">  
      
    function jsApiCall(){  
        WeixinJSBridge.invoke(  
            'getBrandWCPayRequest',<%=(String)request.getAttribute("unifiedOrder")%>, function(res){  
                WeixinJSBridge.log(res.err_msg);  
                //alert(res.err_code+res.err_desc+res.err_msg);  
                if(res.err_msg == "get_brand_wcpay_request:ok" ) {    
                   alert("恭喜你,支付成功!");  
                }else{    
                  alert(res.err_code+res.err_desc+res.err_msg);                  
                }    
            }  
        );  
    }  
  
    function callpay(){  
        if (typeof WeixinJSBridge == "undefined"){  
            if( document.addEventListener ){  
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);  
            }else if (document.attachEvent){  
                document.attachEvent('WeixinJSBridgeReady', jsApiCall);   
                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);  
            }  
        }else{  
            jsApiCall();  
        }  
    }  
    </script>  
  
  <body>
   <input type="button"  value="支付" onclick="callpay()"/>  
  </body>
</html>
